<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="日期" prop="cDate">
        <el-date-picker
          v-model="queryParams.cDate"
          type="date"
          size="small"
          value-format="yyyy-MM-dd"
          @keyup.enter.native="handleQuery"
          placeholder="请输入查询日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>



    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['scrb:sbnyb:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['scrb:sbnyb:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['scrb:sbnyb:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['scrb:sbnyb:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="sbnybList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="日期" align="center" prop="cDate" />
      <el-table-column label="吨产品目标发电量" align="center" prop="cSbnybDcpfdlMb" />
      <el-table-column label="吨产品实际发电量" align="center" prop="cSbnybDcpfdlSj" />
      <el-table-column label="吨产品发生量" align="center" prop="cSbnybDcpffsl" />
      <el-table-column label="总供电" align="center" prop="cSbnybZgd" />
      <el-table-column label="外购电" align="center" prop="cSbnybWgd" />
      <el-table-column label="目标自发电比例" align="center" prop="cSbnybZfdblMb" />
      <el-table-column label="实际自发电比例" align="center" prop="cSbnybZfdblSj" />
      <el-table-column label="当日蒸汽产量" align="center" prop="cSbnybZqclSj" />
      <el-table-column label="累计蒸汽产量" align="center" prop="cSbnybZqclLj" />

      <el-table-column label="当日供水量" align="center" prop="zfree1" />
      <el-table-column label="累计供水量" align="center" prop="zfree2" />

      <el-table-column label="焦炉煤气当日发生量" align="center" prop="cSbnybJlmqFslDr" />
      <el-table-column label="焦炉煤气累计发生量" align="center" prop="cSbnybJlmqFslLj" />
      <el-table-column label="煤气当日发生量" align="center" prop="cSbnybMqfslDr" />
      <el-table-column label="煤气累计发生量" align="center" prop="cSbnybMqfslLj" />
      <el-table-column label="煤气放散率" align="center" prop="cSbnybMqfsrateLj" />
      <el-table-column label="煤气当日耗煤量" align="center" prop="cSbnybHmlDr" />
      <el-table-column label="煤气累计耗煤量" align="center" prop="cSbnybHmlLj" />
      <el-table-column label="焦炉煤气当日放散量" align="center" prop="cSbnybJlmqFsquantityDr" />
      <el-table-column label="焦炉煤气当日放散率" align="center" prop="cSbnybJlmqFsrateDr" />
      <el-table-column label="焦炉煤气累计放散量" align="center" prop="cSbnybJlmqFsquantityLj" />
      <el-table-column label="焦炉煤气累计放散率" align="center" prop="cSbnybJlmqFsrateLj" />
      <el-table-column label="备注" align="center" prop="remake" />
      <el-table-column label="删除标志" align="center" prop="cState" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['scrb:sbnyb:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['scrb:sbnyb:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改设备能源部生产日报录入对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="日期" prop="cDate" >
          <el-date-picker
            v-model="form.cDate"
            :disabled=!isInsert
            type="date"
            size="small"
            value-format="yyyy-MM-dd"
            placeholder="请输入日期">
          </el-date-picker>
        </el-form-item>

        <table>
          <tr>
            <!--<td width="80px"></td>-->
            <td>吨产品发电量<br>目标</td>
            <td>吨产品发电量<br>实际</td>
            <td>总供电</td>
            <td>外购电</td>
            <td>自发电比例<br>目标</td>
            <td>自发电比例<br>实际</td>
            <td>蒸汽产量<br>当日</td>
            <td>蒸汽产量<br>累计</td>
            <td>供水量<br>当日</td>
            <td>供水量<br>累计</td>
          </tr>
          <tr>
            <td><el-input v-model="form.cSbnybDcpfdlMb" placeholder="请输入吨产品发电量目标" /></td>
            <td><el-input v-model="form.cSbnybDcpfdlSj" placeholder="请输入吨产品发电量实际" /></td>
            <td><el-input v-model="form.cSbnybZgd" placeholder="请输入总供电" /></td>
            <td><el-input v-model="form.cSbnybWgd" placeholder="请输入外购电" /></td>
            <td><el-input v-model="form.cSbnybZfdblMb" placeholder="请输入自发电比例目标" /></td>
            <td><el-input v-model="form.cSbnybZfdblSj" placeholder="请输入自发电比例实际" /></td>
            <td><el-input v-model="form.cSbnybZqclSj" placeholder="请输入蒸汽产当日" /></td>
            <td><el-input v-model="form.cSbnybZqclLj" placeholder="请输入蒸汽产量累计" /></td>
            <td><el-input v-model="form.zfree1" placeholder="请输入供水量当日" /></td>
            <td><el-input v-model="form.zfree2" placeholder="请输入供水量累计" /></td>
          </tr>
          </table>

        <table>
          <caption>煤气产供</caption>
          <tr>
            <td width="80px"></td>
            <td>发生（回收）量<br>当日</td>
            <td>发生（回收）量<br>累计</td>
            <td>吨产品<br>发生（回收）量</td>
            <td>放散量<br>当日</td>
            <td>放散量<br>累计</td>
            <td>放散率<br>当日</td>
            <td>放散率<br>累计</td>
          </tr>
          <tr>
            <td>焦炉煤气</td>
            <td><el-input v-model="form.cSbnybJlmqFslDr" placeholder="请输入发生（回收）量当日" /></td>
            <td><el-input v-model="form.cSbnybJlmqFslLj" placeholder="请输入发生（回收）量累计" /></td>
            <td><el-input v-model="form.cSbnybDcpffsl" placeholder="请输入吨产品发生（回收）量" /></td>
            <td><el-input v-model="form.cSbnybJlmqFsquantityDr" placeholder="请输入放散量当日" /></td>
            <td><el-input v-model="form.cSbnybJlmqFsquantityLj" placeholder="请输入放散量累计" /></td>
            <td><el-input v-model="form.cSbnybJlmqFsrateDr" placeholder="请输入放散率当日" /></td>
            <td><el-input v-model="form.cSbnybJlmqFsrateLj" placeholder="请输入放散率累计" /></td>
          </tr>
        </table>

        <table>
          <caption>煤气重整项目</caption>
          <tr>
            <td width="80px"></td>
            <td>当日</td>
            <td>累计</td>
            <td>放散率</td>
            <td></td>
            <td>当日</td>
            <td>累计</td>
          </tr>
          <tr>
            <td>煤气发生量</td>
            <td><el-input v-model="form.cSbnybMqfslDr" placeholder="请输入煤气发生量当日" /></td>
            <td><el-input v-model="form.cSbnybMqfslLj" placeholder="请输入煤气发生量累计" /></td>
            <td><el-input v-model="form.cSbnybMqfsrateLj" placeholder="请输入煤气放散率量" /></td>
            <td>耗煤量</td>
            <td><el-input v-model="form.cSbnybHmlDr" placeholder="请输入耗煤量当日" /></td>
            <td><el-input v-model="form.cSbnybHmlLj" placeholder="请输入耗煤量累计" /></td>
            </tr>
        </table>

        <!--<table>-->
          <!--<caption>焦炉煤气使用量</caption>-->
          <!--<tr>-->
            <!--<td width="80px"></td>-->
            <!--<td>焦炉</td>-->
            <!--<td>氢冶金</td>-->
            <!--<td>解冻库</td>-->
          <!--</tr>-->
          <!--<tr>-->
            <!--<td>当日</td>-->
            <!--<td><el-input v-model="form.zfree3" placeholder="请输入焦炉煤气使用量焦炉当日" /></td>-->
            <!--<td><el-input v-model="form.zfree4" placeholder="请输入焦炉煤气使用量氢冶金当日" /></td>-->
            <!--<td><el-input v-model="form.zfree5" placeholder="请输入焦炉煤气使用量解冻库当日" /></td>-->
          <!--</tr>-->
          <!--<tr>-->
            <!--<td>累计</td>-->
            <!--<td><el-input v-model="form.zfree6" placeholder="请输入焦炉煤气使用量焦炉累计" /></td>-->
            <!--<td><el-input v-model="form.zfree7" placeholder="请输入焦炉煤气使用量氢冶金累计" /></td>-->
            <!--<td><el-input v-model="form.zfree8" placeholder="请输入焦炉煤气使用量解冻库累计" /></td>-->
          <!--</tr>-->
        <!--</table>-->

        <!--<el-form-item label="吨产品目标发电量" prop="cSbnybDcpfdlMb">-->
          <!--<el-input v-model="form.cSbnybDcpfdlMb" placeholder="请输入吨产品目标发电量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="吨产品实际发电量" prop="cSbnybDcpfdlSj">-->
          <!--<el-input v-model="form.cSbnybDcpfdlSj" placeholder="请输入吨产品实际发电量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="吨产品发生量" prop="cSbnybDcpffsl">-->
          <!--<el-input v-model="form.cSbnybDcpffsl" placeholder="请输入吨产品发生量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="总供电" prop="cSbnybZgd">-->
          <!--<el-input v-model="form.cSbnybZgd" placeholder="请输入总供电" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="外购电" prop="cSbnybWgd">-->
          <!--<el-input v-model="form.cSbnybWgd" placeholder="请输入外购电" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="目标自发电比例" prop="cSbnybZfdblMb">-->
          <!--<el-input v-model="form.cSbnybZfdblMb" placeholder="请输入目标自发电比例" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="实际自发电比例" prop="cSbnybZfdblSj">-->
          <!--<el-input v-model="form.cSbnybZfdblSj" placeholder="请输入实际自发电比例" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="当日蒸汽产量" prop="cSbnybZqclSj">-->
          <!--<el-input v-model="form.cSbnybZqclSj" placeholder="请输入当日蒸汽产量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="累计蒸汽产量" prop="cSbnybZqclLj">-->
          <!--<el-input v-model="form.cSbnybZqclLj" placeholder="请输入累计蒸汽产量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="焦炉煤气当日发生量" prop="cSbnybJlmqFslDr">-->
          <!--<el-input v-model="form.cSbnybJlmqFslDr" placeholder="请输入焦炉煤气当日发生量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="焦炉煤气累计发生量" prop="cSbnybJlmqFslLj">-->
          <!--<el-input v-model="form.cSbnybJlmqFslLj" placeholder="请输入焦炉煤气累计发生量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="煤气当日发生量" prop="cSbnybMqfslDr">-->
          <!--<el-input v-model="form.cSbnybMqfslDr" placeholder="请输入煤气当日发生量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="煤气累计发生量" prop="cSbnybMqfslLj">-->
          <!--<el-input v-model="form.cSbnybMqfslLj" placeholder="请输入煤气累计发生量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="煤气放散率" prop="cSbnybMqfsrateLj">-->
          <!--<el-input v-model="form.cSbnybMqfsrateLj" placeholder="请输入煤气放散率" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="煤气当日耗煤量" prop="cSbnybHmlDr">-->
          <!--<el-input v-model="form.cSbnybHmlDr" placeholder="请输入煤气当日耗煤量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="煤气累计耗煤量" prop="cSbnybHmlLj">-->
          <!--<el-input v-model="form.cSbnybHmlLj" placeholder="请输入煤气累计耗煤量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="焦炉煤气当日放散量" prop="cSbnybJlmqFsquantityDr">-->
          <!--<el-input v-model="form.cSbnybJlmqFsquantityDr" placeholder="请输入焦炉煤气当日放散量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="焦炉煤气当日放散率" prop="cSbnybJlmqFsrateDr">-->
          <!--<el-input v-model="form.cSbnybJlmqFsrateDr" placeholder="请输入焦炉煤气当日放散率" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="焦炉煤气累计放散量" prop="cSbnybJlmqFsquantityLj">-->
          <!--<el-input v-model="form.cSbnybJlmqFsquantityLj" placeholder="请输入焦炉煤气累计放散量" />-->
        <!--</el-form-item>-->
        <!--<el-form-item label="焦炉煤气累计放散率" prop="cSbnybJlmqFsrateLj">-->
          <!--<el-input v-model="form.cSbnybJlmqFsrateLj" placeholder="请输入焦炉煤气累计放散率" />-->
        <!--</el-form-item>-->
        <el-form-item label="备注" prop="remake">
          <el-input v-model="form.remake" placeholder="请输入备注" />
        </el-form-item>
        <!--<el-form-item label="删除标志" prop="cState">-->
          <!--<el-input v-model="form.cState" placeholder="请输入删除标志" />-->
        <!--</el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listSbnyb, getSbnyb, delSbnyb, addSbnyb, updateSbnyb } from "@/api/scrb/sbnyb";

export default {
  name: "Sbnyb",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 设备能源部生产日报录入表格数据
      sbnybList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        cSbnybDcpfdlMb: null,
        cSbnybDcpfdlSj: null,
        cSbnybDcpffsl: null,
        cSbnybZgd: null,
        cSbnybWgd: null,
        cSbnybZfdblMb: null,
        cSbnybZfdblSj: null,
        cSbnybZqclSj: null,
        cSbnybZqclLj: null,
        cSbnybJlmqFslDr: null,
        cSbnybJlmqFslLj: null,
        cSbnybMqfslDr: null,
        cSbnybMqfslLj: null,
        cSbnybMqfsrateLj: null,
        cSbnybHmlDr: null,
        cSbnybHmlLj: null,
        cSbnybJlmqFsquantityDr: null,
        cSbnybJlmqFsrateDr: null,
        cSbnybJlmqFsquantityLj: null,
        cSbnybJlmqFsrateLj: null,
        remake: null,
        zfree1: null,
        zfree2: null,
        zfree3: null,
        zfree4: null,
        zfree5: null,
        zfree6: null,
        zfree7: null,
        zfree8: null,
        zfree9: null,
        zfree10: null,
        zfree11: null,
        zfree12: null,
        zfree13: null,
        zfree14: null,
        zfree15: null,
        cState: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      isInsert:true,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询设备能源部生产日报录入列表 */
    getList() {
      this.loading = true;
      listSbnyb(this.queryParams).then(response => {
        this.sbnybList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        cDate: null,
        cSbnybDcpfdlMb: null,
        cSbnybDcpfdlSj: null,
        cSbnybDcpffsl: null,
        cSbnybZgd: null,
        cSbnybWgd: null,
        cSbnybZfdblMb: null,
        cSbnybZfdblSj: null,
        cSbnybZqclSj: null,
        cSbnybZqclLj: null,
        cSbnybJlmqFslDr: null,
        cSbnybJlmqFslLj: null,
        cSbnybMqfslDr: null,
        cSbnybMqfslLj: null,
        cSbnybMqfsrateLj: null,
        cSbnybHmlDr: null,
        cSbnybHmlLj: null,
        cSbnybJlmqFsquantityDr: null,
        cSbnybJlmqFsrateDr: null,
        cSbnybJlmqFsquantityLj: null,
        cSbnybJlmqFsrateLj: null,
        remake: null,
        zfree1: null,
        zfree2: null,
        zfree3: null,
        zfree4: null,
        zfree5: null,
        zfree6: null,
        zfree7: null,
        zfree8: null,
        zfree9: null,
        zfree10: null,
        zfree11: null,
        zfree12: null,
        zfree13: null,
        zfree14: null,
        zfree15: null,
        cState: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.cDate)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.isInsert=true;
      this.title = "添加设备能源部生产日报录入";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const cDate = row.cDate || this.ids
      getSbnyb(cDate).then(response => {
        this.form = response.data;
        this.open = true;
        this.isInsert=false;
        this.title = "修改设备能源部生产日报录入";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (!this.isInsert) {
            updateSbnyb(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addSbnyb(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const cDates = row.cDate || this.ids;
      this.$modal.confirm('是否确认删除设备能源部生产日报录入编号为"' + cDates + '"的数据项？').then(function() {
        return delSbnyb(cDates);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('scrb/sbnyb/export', {
        ...this.queryParams
      }, `sbnyb_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style lang="scss" scoped>
  table
  {
    border-collapse: collapse;
    margin: 0 auto;
    text-align: center;
  }
  table td, table th
  {
    border: 2px solid #cad9ea;
    color: #666;
    height: 30px;
  }
  table thead th
  {
    background-color: #CCE8EB;
    width: 100px;
  }
  table tr:nth-child(odd)
  {
    background: #fff;
  }
  table tr:nth-child(even)
  {
    background: #F5FAFA;
  }
</style>

